package com.aurora_manito.xiaomi.Controller;


import com.aurora_manito.xiaomi.entity.GoodsType;
import com.aurora_manito.xiaomi.service.GoodsService;
import com.aurora_manito.xiaomi.service.GoodsTypeService;
import com.aurora_manito.xiaomi.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Aurora_Manito
 * @since 2020-05-27
 */
@RestController
@RequestMapping("/xiaomi/goods-type")
public class GoodsTypeController {
    @Autowired
    GoodsTypeService goodsTypeService;
    //获取商品类型
    @GetMapping(value = "/goodTypeList", produces = {"application/json;charset=UTF-8"})
    @ResponseBody //序列化--》类型转换  --》jackson ---Json
    public ResponseMessage goodTypeList()
    {
        List<GoodsType> goodTypeList=goodsTypeService.getTypeByLevel(1);
        if(goodTypeList!=null)
        {

            return ResponseMessage.success().addObject("goodTypeList",goodTypeList);
        }else{
            return ResponseMessage.error();
        }

    }
}

